﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>人员岗位</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
    <script type="text/html" id="barDemo">
        @if (ViewData["operate"].ToString().Contains("update"))
        {
          
            <a title="删除信息" href="javascript:;" lay-event="del"><i class="layui-icon">&#xe640;</i></a>
        }
    </script>

</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">

                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="userCode" placeholder="员工工号" autocomplete="off" class="layui-input" id="userCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="userName" placeholder="员工姓名" autocomplete="off" class="layui-input" id="userName">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <select id="gxCode" name="gxCode" class="gxCode">
                                    <option value="">生产工序</option>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select name="gangwei" id="gangwei" class="gw">
                                    <option value="">生产岗位</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-filter="sreach" id="userSearch" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                            </div>
                        </form>
                        <br />
   
                     @if (ViewData["operate"].ToString().Contains("update"))
        {
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" id="btnAdd" type="button" onclick="openWin()"><i class="layui-icon"> </i>添加岗位</button>
                            </div>
                          
                     }

                        </div>
              
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script type="text/javascript">
    $(function () {
        bargxInfo();
        CommonData('scgw', "gw");
        loadData();
    })
    //赋值菜单列表
    function loadData() {
        layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element', 'slider'], function () {
            var laydate = layui.laydate //日期
                 , laypage = layui.laypage //分页
                 , layer = layui.layer //弹层
                 , table = layui.table //表格
                 , carousel = layui.carousel //轮播
                 , upload = layui.upload //上传
                 , element = layui.element //元素操作
                 , slider = layui.slider //滑块
            var condition = JSON.stringify(FormToJson("qForm"));

            //给table赋值
            table.render({
                elem: '#list'
                , url: '../Basis/GetDataList?dataType=usp&condition=' + condition //数据接口
                , title: '显示数据'
                , page: true //开启分页
                , even: true
                , limits: [20, 50, 80, 100]
                , toolbar: false //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , defaultToolbar: ['exports']
             , cols: [[ //标题栏  表头
               { field: 'id', title: 'id', width: 80 }
             , { field: 'userCode', title: '员工工号', width: 100 }
             , { field: 'userName', title: '员工姓名', width: 130 }
             , { field: 'gangweiName', title: '岗位名称', width: 120 }
             , { field: 'gxName', title: '工序名称', width: 100 }
             , { field: 'machineName', title: '生产机台', width: 120 }
             , { field: 'zhanbi', title: '占比', width: 100 }
             , { field: 'right', title: '数据操作', toolbar: '#barDemo', width: 110, fixed: 'right' }
             ]], done: function (res, curr, count) {
                 $("[data-field='id']").css('display', 'none');//隐藏列
             }
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
                if (obj.event === 'del') {
                    layer.confirm('确认要删除该数据？', function (index) {
                        var info = DelData(data.id);
                        if (info.Result) {
                            obj.del();
                        } else {
                            layer.msg(info.Message);
                        }
                        layer.close(index);
                    });
                } else if (obj.event === 'viewReport') {
                    
                }

            });
         
        });
    }

    function DelData(dataId) {
        var info = undefined;
        $.ajax({
            url: "../Basis/DelUserPosition",
            data: { dataId: dataId },
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {

                info = data;
            }
        });
        return info;
    }

    function openWin() {
        InfoOpenPage("../Basis/UpdateUserPosition?dataId=0", "人员岗位信息添加", "85%", "90%");
    }

    function bargxInfo() {
        $.ajax({
            url: "../Basis/BarTypes",
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {
                if (data.Result) {
                    var datas = data.Data;
                    for (var i = 0; i < datas.length; i++) {
                        $(".gxCode").append("<option value=\"" + datas[i]["cCode"] + "\" >" + datas[i]["cName"] + "</option>");
                    }

                }
            }
        });
    }
</script>